//
//  HWInviteRewardHeader.swift
//  HWanGame
//
//  Created by 王昌健 on 2022/9/15.
//  Copyright © 2022 94Wan. All rights reserved.
//

import UIKit

class HWInviteRewardHeader: UITableViewHeaderFooterView {
    var price:UILabel!
    var priceLabel:UILabel!
    var bonus:UILabel!
    var bonusLabel:UILabel!
    var model:HWInviteRechargeModel? {
        didSet {
            price.text = model?.pay
            priceLabel.text = model?.pay_title
            bonus.text = model?.jiangjin
            bonusLabel.text = model?.jiangjin_title
        }
    }
    class func headerOrFooterWithTableView(tableView:UITableView) -> (HWInviteRewardHeader) {
        let reUse:String = "HWInviteRewardHeader"
        
        var headerOrFooter = tableView.dequeueReusableHeaderFooterView(withIdentifier: reUse)
        
        if headerOrFooter == nil {
            headerOrFooter = HWInviteRewardHeader.init(reuseIdentifier: reUse)
        }
        
        return headerOrFooter as! HWInviteRewardHeader
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier)
        initUI()
        initFrame()
    }
    
    
    func initUI() -> Void {
        backgroundView = UIView()
        contentView.backgroundColor = .colorWithHexString(hexString: "#F7F7F7")
        
        price = HWLabel.createBoldLabel(title: "", color: "#FF726A", font: 27*widthScale)
        price.textAlignment = .center
        contentView.addSubview(price)
        
        priceLabel = HWLabel.createLabel(title: "累充金额", color: "#333333", font: 13*widthScale)
        priceLabel.textAlignment = .center
        contentView.addSubview(priceLabel)
        
        bonus = HWLabel.createBoldLabel(title: "", color: "#FF726A", font: 27*widthScale)
        bonus.textAlignment = .center
        contentView.addSubview(bonus)
        
        bonusLabel = HWLabel.createLabel(title: "激励奖金", color: "#333333", font: 13*widthScale)
        bonusLabel.textAlignment = .center
        contentView.addSubview(bonusLabel)
        
    }
    
    func initFrame() -> Void {
        price.snp.makeConstraints { make in
            make.left.equalToSuperview()
            make.top.equalTo(27*widthScale)
            make.height.equalTo(38*widthScale)
            make.right.equalTo(contentView.snp.centerX)
        }
        
        priceLabel.snp.makeConstraints { make in
            make.left.right.equalTo(price)
            make.top.equalTo(price.snp.bottom).offset(1*widthScale)
            make.height.equalTo(18*widthScale)
        }
        
        bonus.snp.makeConstraints { make in
            make.left.equalTo(snp.centerX)
            make.top.equalTo(27*widthScale)
            make.height.equalTo(38*widthScale)
            make.right.equalToSuperview()
        }
        
        bonusLabel.snp.makeConstraints { make in
            make.left.right.equalTo(bonus)
            make.top.equalTo(bonus.snp.bottom).offset(1*widthScale)
            make.height.equalTo(18*widthScale)
        }
    }
}
